package com.hky.front_end_monitor.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hky.front_end_monitor.constant.Constants;
import com.hky.front_end_monitor.entity.SysFirstPaint;
import com.hky.front_end_monitor.service.SysFirstPaintService;
import com.hky.front_end_monitor.mapper.SysFirstPaintMapper;
import com.hky.front_end_monitor.utils.NumberUtils;
import org.springframework.stereotype.Service;

import java.util.LinkedHashMap;
import java.util.Map;

/**
 * @author hello
 * @description 针对表【sys_first_paint】的数据库操作Service实现
 * @createDate 2022-07-28 22:40:40
 */
@Service
public class SysFirstPaintServiceImpl extends ServiceImpl<SysFirstPaintMapper, SysFirstPaint>
        implements SysFirstPaintService {

    @Override
    public boolean storeFp(String uuid, Map map) {
        SysFirstPaint fp = new SysFirstPaint();
        fp.setFirstPaintId(uuid);
        Map data = ((Map) (map.get(Constants.metricsName.FP.value)));
        fp.setStartTime(NumberUtils.toDouble(data.get("startTime")));
        LinkedHashMap entryInfo = (LinkedHashMap) (data).get("entry");
        fp.setEntryName((String) entryInfo.get("name"));
        fp.setEntryType((String) entryInfo.get("entryType"));
        fp.setEntryStartTime(NumberUtils.toDouble(entryInfo.get("startTime")));
        fp.setEntryDuration(NumberUtils.toDouble(entryInfo.get("duration")));
        return this.save(fp);
    }
}




